package com.example.smartfridge;

import java.util.Date;
import java.util.List;

import com.id2216.fridge.data.DBHelper;
import com.id2216.fridge.data.FridgeItem;
import com.id2216.fridge.data.ShoppingItem;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.AdapterView.OnItemClickListener;

public class ShoppingListActivity extends Activity {

	RadioButton fridge;
	RadioButton list;
	RadioButton more;
	Button addNew;
	Button toFridge;
	Button delete;
	
    private List<ShoppingItem> shoppingItemList;      
	DBHelper db;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list);
		
		fridge = (RadioButton)this.findViewById(R.id.radio0);
		list = (RadioButton)this.findViewById(R.id.radio1);
		more = (RadioButton)this.findViewById(R.id.radio2);
		addNew = (Button)this.findViewById(R.id.button1);
		toFridge = (Button)this.findViewById(R.id.button2);
		delete = (Button)this.findViewById(R.id.button3);
		
		
		
        db = new DBHelper(this.getApplicationContext());
        shoppingItemList = db.getAllShoppingItem();
        
        ShoppingAdapter adapter = new ShoppingAdapter(this,
                R.layout.shopping_item_cell, shoppingItemList);

        ListView listView = (ListView) this.findViewById(R.id.shoppingListView); 
        listView.setAdapter(adapter); 
        listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) 
			{
				Date date = new Date();
				ShoppingItem item = shoppingItemList.get(position);
				
			}});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.list, menu);
		return true;
	}

}
